#!/usr/bin/env python2.7
# -*- coding:utf-8 -*- 

# account.py

import os, sys
from metlib.kits import *
# from account.models import *
from weblib.django.user import *

account_types = [
    # name, desc, priority
    ('gift', u'赠送币', 10),
    ('cash', u'现金', 50),
]

account_books = [
    # name, desc
    ('data', u'数据产品账本')
]


def run():
    print "Generating/Updating account types ..."
    for name, desc, priority in account_types:
        print name, desc, priority
        # AccountType.objects.update_or_create(name=name,
        #                                      defaults={
        #                                          'desc': desc,
        #                                          'priority': priority
        #                                      })

    print "Generating/Updating account books ..."
    for name, desc in account_books:
        print name, desc
        # AccountBook.objects.update_or_create(name=name,
        #                                      defaults={
        #                                          'desc': desc
        #                                      })

    print "Generating user's accounts ..."
    UserModel = get_user_model()
    for user in UserModel.objects.all():
        pass
        # for acc_type in AccountType.objects.all():
        #     account_name = u'%s:%s' % (user.username, acc_type.name)
        #     acc, created = Account.objects.get_or_create(name=account_name, defaults={
        #         "user": user,
        #         "type": acc_type,
        #         "priority": acc_type.priority,
        #     })
        #     if created:
        #         print account_name
